package com.jy.rhin.facade.controller.notification;

import com.jy.framework.base.entity.Page;
import com.jy.framework.base.entity.Result;
import com.jy.rhin.application.infra.NotificationApplicationService;
import com.jy.rhin.infra.repo.notfication.topic.query.TopicQueryHandler;
import com.jy.rhin.sdk.dto.notification.req.IdDto;
import com.jy.rhin.sdk.dto.notification.req.TopicExpDto;
import com.jy.rhin.sdk.dto.notification.req.TopicQueryPageReqDto;
import com.jy.rhin.sdk.dto.notification.resp.TopicDetailDto;
import com.jy.rhin.sdk.dto.notification.resp.TopicInfoDto;
import com.jy.rhin.sdk.dto.notification.resp.TopicQueryDto;
import com.jy.rhin.sdk.dto.notification.resp.TopicShortDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author dhl
 * @date 2022/7/4
 * @Description
 */
@RestController
@RequestMapping("/notification/topic")
@Api(tags = "事件总线api", value = "主题记录api")
@Slf4j
public class TopicBizController {

    @Resource
    NotificationApplicationService notificationApplicationService;

    @Resource
    TopicQueryHandler topicQueryHandler;

    @ApiOperation(value = "主题记录api-分页查询主题列表")
    @GetMapping("/queryPage")
    public Result<Page<TopicInfoDto>> queryPage(TopicQueryPageReqDto dto) {
        return Result.success(topicQueryHandler.queryPage(dto));
    }

    @ApiOperation(value = "主题记录api-查询主题详情")
    @GetMapping("/queryTopicDetail")
    public Result<TopicDetailDto> queryTopicDetail(IdDto dto) {
        return Result.success(topicQueryHandler.queryTopicDetail(dto.getId()));
    }

    @ApiOperation(value = "主题记录api-查询主题列表")
    @GetMapping("/queryTopicList")
    public Result<List<TopicShortDto>> queryTopicList(){
        return Result.success(topicQueryHandler.queryTopicList());
    }

    @ApiOperation(value = "主题记录api-根据主题表达式获取预存函数列表")
    @GetMapping("/queryTopicQueryAndTopicFilterList")
    public Result<List<TopicQueryDto>> queryTopicQueryAndTopicFilterList(TopicExpDto dto){
        return Result.success(topicQueryHandler.queryTopicQueryAndTopicFilterList(dto));
    }
}
